//
//  CowSay.swift
//  hello
//
//  Created by 赵康 on 2024/10/19.
//

import Vapor

struct CowSay: AsyncCommand {
	var help: String {
		"让一头牛说话"
	}
	struct Signature: CommandSignature {
		@Argument(name: "message")
		var message: String
		
		@Option(name: "eyes", short: "e")
		var eyes: String?
		
		@Option(name: "tongue", short: "t")
		var tongue: String?
		
	}
	func run(using context: CommandContext, signature: Signature) async throws {
		let eyes = signature.eyes ?? "oo"
		let tongue = signature.tongue ?? " "
		let cow = #"""
				< $M >
							\   ^__^
							 \  ($E)\_______
									(__)\       )\/\
									 $T ||----w |
											||     ||
"""#
			.replacingOccurrences(of: "$M", with: signature.message)
			.replacingOccurrences(of: "$E", with: eyes)
			.replacingOccurrences(of: "$T", with: tongue)
		context.console.output(cow, style: .plain, newLine: true)
	}
}
